home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / Visual Basic 6.0 Utilities / Multi-Language Add-In for Visual Basic 6.0 / MultiLang.msi / _AF3F81AE4EF811D5BEBE0020182C1E5C < prev    next >
Encoding:
Text File  |  2001-08-31  |  2.2 KB  |  65 lines

  1. Attribute VB_Name = "MlStringModule"
  2. Option Explicit
  3.  
  4. Public ml_CurrentLanguageId As Long
  5. Public Const ml_LanguageCount As Long = 2
  6. Public ResLoader As New ResourceReader
  7. Public InVbIde As Boolean
  8.  
  9. Public Function ml_string(ByVal StringID As Long, Optional ByVal Text As String = "") As String
  10.   'NOTE: ResLoader fails when running in the VB debugger!
  11.   If InVbIde Then
  12.     ml_string = LoadResString(StringID)
  13.   Else
  14.     ml_string = ResLoader.ResString(StringID, ml_CurrentLanguageId)
  15.   End If
  16. End Function
  17.  
  18. Public Function ml_LanguageName(ByVal LangIndex As Long) As String
  19.   Select Case LangIndex
  20.     Case 2057: ml_LanguageName = "English (United Kingdom)"
  21.     Case 1031: ml_LanguageName = "German (Standard)"
  22.     Case Else: ml_LanguageName = "Invalid Language Index"
  23.   End Select
  24. End Function
  25.  
  26. Public Sub ml_ChangeLanguage(ByVal LanguageID As Long, ByVal Language As String)
  27.   
  28.   'If an application uses UserControls or Class Modules compiled as separate
  29.   'projects, then these projects may (a) not support the same languages or
  30.   '(b) not use the same ID number for a given language.
  31.   'If the language is changed at run time, an event can be fired via the
  32.   'MLSupport object, and received in all projects.
  33.   'This function checks whether the ID and Language name match before accepting
  34.   'the language change. If they do not match, then it searches for language
  35.   'using the language name not the ID. If the language is not found, then the
  36.   'language is not changed.
  37.   
  38.   'Check whether the LanguageID and the Language match in this project.
  39.   'Use StrComp() for case insensitive comparison
  40.   If StrComp(ml_LanguageName(LanguageID), Language, vbTextCompare) = 0 Then
  41.     ml_CurrentLanguageId = LanguageID
  42.   Else
  43.     'LanguageID may be different in this project.
  44.     'Search for the language string.
  45.     For LanguageID = 0 To ml_LanguageCount - 1
  46.       If StrComp(ml_LanguageName(LanguageID), Language, vbTextCompare) = 0 Then
  47.         ml_CurrentLanguageId = LanguageID
  48.         Exit For
  49.       End If
  50.     Next
  51.   End If
  52.   
  53. End Sub
  54.  
  55.  
  56.  
  57. Public Function ml_LanguageIds() As Variant
  58.   ml_LanguageIds = Array(2057, 1031)
  59. End Function
  60.  
  61. Public Function SetInVbIde() As Boolean
  62.   InVbIde = True
  63.   SetInVbIde = True
  64. End Function
  65.